package com.rangeapp;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TabHost;


public class HomeActivity extends TabActivity {

    TabHost tabHost;
    public static String Tab="";

    Button homeButton, trendsButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);


        homeButton = (Button) findViewById(R.id.homeButton);
        trendsButton = (Button) findViewById(R.id.trendsButton);


        tabHost = getTabHost();

        // Tab for tab1
        TabHost.TabSpec spec1 = tabHost.newTabSpec("Tab1");
        // setting Title and Icon for the Tab
        spec1.setIndicator("Tab1");
        Intent Intent1 = new Intent(this, MainActivity.class);
        spec1.setContent(Intent1);

        // Tab for tab2
        TabHost.TabSpec spec2 = tabHost.newTabSpec("Tab2");
        // setting Title and Icon for the Tab
        spec2.setIndicator("Tab2");
        Intent Intent2 = new Intent(this, MainActivity.class);
        spec2.setContent(Intent2);


        // Adding all TabSpec to TabHost
        tabHost.addTab(spec1); // Adding tab1
        tabHost.addTab(spec2); // Adding tab2
    }



    public void tabHandler(View target) {
        if (target.getId() == R.id.homeButton) {
            Tab="this is Tab myScream";
            tabHost.setCurrentTab(0);

        } else if (target.getId() == R.id.trendsButton) {
            Tab="this is myFavorites";
            tabHost.setCurrentTab(1);

        }
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_home, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}
